//
//  SubscriptionViewController.m
//  MXClassroom
//
//  Created by 你个LB on 16/9/8.
//  Copyright © 2016年 你个LB. All rights reserved.
//

#import "SubscribeViewController.h"

@interface SubscribeViewController ()

@end

@implementation SubscribeViewController

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.title = @"订阅";
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self initDataSource];
    
    [self initTableView];
    
    
}

- (void)initDataSource{
    NSMutableArray * models = [NSMutableArray array];

    NSArray * data = @[@{@"headImg":@"佛学科学_点击150px.png",
                         @"title":@"菠萝蜜多心经",
                         @"newestClassHour":@"2016-07-01 13:00-14:00",
                         @"teachTime":@"1天前",
                         @"teacher":@"仁泽法师"},
                       @{@"headImg":@"佛学科学_点击150px.png",
                         @"title":@"菠萝蜜多哈哈",
                         @"newestClassHour":@"2016-06-01 13:00-14:00",
                         @"teachTime":@"2天前",
                         @"teacher":@"惠普法师"}];
    
    for (int i = 0; i < 2; i ++) {
        SubscribeModel * subscribe = [[SubscribeModel alloc] initWithContentDic:data[i]];
        [models addObject:subscribe];
    }
    _dataList = models;
}


- (void)initTableView{
    UITableView * tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kScreen_width, kScreen_height - 64) style:UITableViewStylePlain];
    tableView.dataSource = self;
    tableView.delegate = self;
    [self.view addSubview:tableView];
}

#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _dataList.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    SubscribeTableViewCell * cell = [SubscribeTableViewCell cellWithTableView:tableView];
    
    cell.subscribe = _dataList[indexPath.row];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 86;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
